<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <link rel="shortcut icon" href="/img/favicon.html">

    <title>小時光科技 - 電銷CRM</title>

    <!-- Bootstrap core CSS -->
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="/assets/font-awesome/css/font-awesome.css" rel="stylesheet"/>
    <!-- Custom styles for this template -->
    <link href="/css/style.css" rel="stylesheet">
    <link href="/css/style-responsive.css" rel="stylesheet"/>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
    <script src="/js/html5shiv.js"></script>
    <script src="/js/respond.min.js"></script>
    <![endif]-->

    <script src="/layui/layui.js"></script>
    <script src="/js/global.js"></script>
    <script src="/js/jquery-1.8.3.min.js"></script>
</head>

<body class="login-body" style="background: url('/img/bg.jpg') no-repeat fixed top;">

<div class="container" >

    <form class=" layui-form form-signin" action="index.html">
        <h2 class="form-signin-heading">CRM用戶 - 登录</h2>
        <div class="login-wrap">
            <input id="Name" name="Name" type="text" class="form-control" required lay-verify="required"
                   placeholder="賬戶" autofocus>
            <input id="Pass" name="Pass" type="password" class="form-control" required lay-verify="required"
                   placeholder="密碼">

            <label class="checkbox">
                <input id="RemeberPassword" type="checkbox" value="yes" onchange="mb_RemeberChange">记住密码
                <span class="pull-right"> <a href="#">忘记密码?</a></span>
            </label>
            <button class="btn btn-lg btn-login btn-block" type="submit" lay-submit lay-filter="formLogin">登 录</button>
        </div>
    </form>
</div>
<script>
    layui.use('form', function () {
        var form = layui.form;
        //監聽提交
        form.on('submit(formLogin)', function (data) {
            var fields = data.field;
            global.post('/index.php/superadmin/index/mb_Login', fields, function (msg) {
                if (msg['code'] == ErrCode_Normal) {
                    layer.msg('登录成功', {
                        offset: '15px'
                        , icon: 1
                        , time: 1000
                    }, function () {
                        window.location.href = '/index.php/user/home';
                    });

                    if ($('#RemeberPassword').prop('checked') == true) {
                        mb_SetCookie('CRMUser_Name', fields.Name, 7);
                        mb_SetCookie('CRMUser_Pass', fields.Pass, 7);
                    } else {
                        mb_DelCookie('CRMUser_Name');
                        mb_DelCookie('CRMUser_Pass');
                    }

                    return false;
                } else {
                    mb_OnMessage(msg);
                    return false;
                }
            });
            return false;
        });

        if (mb_GetCookie('CRMUser_Name') != '') {
            $('#RemeberPassword').attr('checked', 'checked');
            $('#Name').val(mb_GetCookie('CRMUser_Name'));
            $('#Pass').val(mb_GetCookie('CRMUser_Pass'));
        }
    });
</script>
</body>
</html>
